import http from "../../utils/http"
import { createSlice } from "@reduxjs/toolkit"

export const user = createSlice({
    name: "user",
    initialState: {
        info:{}
    },
    reducers: {
        setUser: (state, action) => {
            state.info = action.payload
        },
    },
})
export const { setUser } = user.actions
export default user.reducer

export function getUserAction() {
    return async (dispatch) => {
        const { data } = await http.get("/user/profile")
        dispatch(setUser(data))
    }
}